let fs=require('fs')
let path=require('path')
let http=require('http')
let url=require('url')

http.createServer((req,res)=>{

    if(req.url==='/favicon.ico') return;
    let pathname=url.parse(req.url).pathname;

    // 返回首页
    if(pathname==='/'){
        res.end(fs.readFileSync(path.resolve(__dirname, './index.html')))
    }
    if(pathname==='/log'){
        let str='';
        req.on('data',(chunk)=>{
            str+=chunk;
        }) 
        req.on('end',()=>{
            str=JSON.parse(str)
            console.log(str);
            
        });
        res.end('123')
    }
}).listen(5000)